﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Json;
using System.Text;
using Newtonsoft.Json;

namespace Super.DomainService
{
    public class JsonHelper
    {
        /// <summary>
        /// 反序列化 json To Object
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="sJson"></param>
        /// <returns></returns>
        public static List<T> Deserialize<T>(string sJson) where T : class
        {
            return JsonConvert.DeserializeObject<List<T>>(sJson);

        }

        /// <summary>
        /// 序列化  Object to json
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="data"></param>
        /// <returns></returns>
        public static string Serialize<T>(T data)
        {
            return JsonConvert.SerializeObject(data);
        }
    }
}
